package com.yh.csx.event.domain;

import com.yh.csx.event.common.exception.EventException;
import com.yh.csx.event.common.exception.ExceptionEnum;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 1废弃，0正常
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum DelFlagEnum {
    DEl(1, "删除"),
    NORMAL(0, "正常"),
    ;
    private Integer code;
    private String name;

    public static DelFlagEnum getEventStatusEnum(Integer code) {
        return Arrays.stream(values()).filter(event -> event.getCode().equals(code))
                .findFirst().orElseThrow(() -> new EventException(ExceptionEnum.NO_STATUS_TYPE, null == code ? "null" : code.toString()));
    }
}
